home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 November / CHIP Kasım 1997.iso / ARACLAR / TER500 / 500TER._XE / SCRIPT.EXE / AUTOCALL.TSL < prev    next >
Encoding:
Text File  |  1997-04-08  |  2.9 KB  |  151 lines

  1. % -----------------------------------------------------------------------------
  2. % Login automation                                     *TERMINATE PRESCRIPTION*
  3. % -----------------------------------------------------------------------------
  4. %
  5. %  Version          : 1.00
  6. %  Filename         : AUTOCALL.TSL
  7. %  Company          : SerWiz Comm
  8. %  Programmer       : Bo Bendtsen
  9. %  Module created   : 08 Apr 1997
  10. %  Latest revision  : 08 Apr 1997 by Bo Bendtsen
  11. %  Language/version : Terminate Prescription 1.00
  12. %  Remarks          : Demonstration of how to call, login and hangup
  13. %
  14. % -----------------------------------------------------------------------------
  15.  
  16. Set DialNumber  = "01713941230"
  17. Set Username    = "Bo Bendtsen"
  18. Set Password    = "secret"
  19.  
  20. Set DialCmd     = "ATDT"
  21. Set DialTime    = 60
  22. Set Retries     = 3
  23. Set RetryDelay  = 5
  24. Set SendEscapes = 0
  25.  
  26. Function GetString(ReturnString,Timeout)
  27. Set LastChar=""
  28. Set Key=0
  29. ResetTimer 1,Timeout
  30. Repeat
  31.   If CharsWaiting<>0
  32.     Set LastChar=GetChar
  33.     If (LastChar<>Chr(13)) & (LastChar<>Chr(10))
  34.       Set ReturnString=ReturnString+LastChar
  35.     Endif
  36.   Endif
  37.   If Keypressed<>0
  38.     Set Key = GetKey
  39.   Endif
  40. Until (LastChar=Chr(10)) | (TimerExpired(1)=1) | (Key=27)
  41. EndFunc ReturnString
  42.  
  43. Function SendModem(ModemString)
  44.   Send ModemString
  45.   Send Chr(13)
  46.   Wait 250
  47. EndFunc 0
  48.  
  49. Set Tries=0
  50.  
  51. :DialUp
  52. PrintLn
  53. PrintLn "Dialling: "+DialNumber
  54. SendModem(DialCmd+DialNumber)
  55. Set ModemResult=GetString("",3)
  56. If Key=27
  57.   Goto End
  58. Endif
  59.  
  60. :WaitString
  61. Set ModemResult=GetString("",DialTime)
  62. If Key=27
  63.   Goto End
  64. Endif
  65.  
  66. If ModemResult=""
  67.   If TimerExpired(1)=1
  68.     Goto End
  69.   Endif
  70.   Goto WaitString
  71. Endif
  72.  
  73. If Pos("CONNECT",ModemResult)=1
  74.   Goto Connected
  75. Endif
  76.  
  77. If ModemResult = "RINGING"
  78.   PrintLn "Ringing"
  79.   Goto WaitString
  80. Endif
  81.  
  82. If ModemResult = "BUSY"
  83.   Goto Busy
  84. Endif
  85.  
  86. If ModemResult = "NO CARRIER"
  87.   Goto NoCarrier
  88. Endif
  89.  
  90. If ModemResult = "NO DIALTONE"
  91.   Goto NoDialTone
  92. Endif
  93.  
  94. PrintLn "Unknown result: '"+ModemResult+"'"
  95. Goto End
  96.  
  97. :Connected
  98.  PrintLn "Connected"
  99.  Wait 200
  100.  If SendEscapes=1
  101.    Send Chr(27)+Chr(27)
  102.  Endif
  103.  WaitFor "Name",30
  104.  If IOResult<>0
  105.    Goto End
  106.  Endif
  107.  Send Username+Chr(13)
  108.  WaitFor "Password",30
  109.  If IOResult<>0
  110.    Goto End
  111.  Endif
  112.  
  113.  Wait 100
  114.  
  115.  % Here you could insert you own code to automate the task you need
  116.  % to perform like uploading or downloading a file.
  117.  % You can also LEARN a script and insert at this location.
  118.  
  119.  % Download 1
  120.  % Upload 1,"C:\AUTOEXEC.BAT C:\CONFIG.SYS"
  121.  
  122.  Wait 100
  123.  
  124.  Goto End
  125.  
  126. :Busy
  127.  PrintLn "Line was Busy"
  128.  Set Tries=Tries+1
  129.  If (Tries<Retries) | (Retries=0)
  130.    Send Chr(13)+Chr(13)
  131.    Wait 100
  132.    PrintLn "Retrying in "+RetryDelay+" seconds"
  133.    Wait RetryDelay*100
  134.    Goto DialUp
  135.  Endif
  136.  PrintLn "To many busytries"
  137.  Goto End
  138.  
  139. :NoCarrier
  140.  PrintLn "No carrier"
  141.  Goto End
  142.  
  143. :NoDialTone
  144.  PrintLn "No dialtone"
  145.  Goto End
  146.  
  147. :End
  148.  Hangup
  149.  PrintLn "End."
  150.  
  151.